package com.yue.yadmin.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 菜单类型    1：菜单   2：按钮
 * 廖欣跃
 * Mon Jul 09 14:49:11 CST 2018
 */
public enum EnumMenuType {
	/**
	 *[1,"菜单"]
	 */
	MENU(1,"菜单"),
	/**
	 *[2,"按钮"]
	 */
	BUTTON(2,"按钮");
	private int type;
	private String desc;
	public void setType(int type){
		this.type=type;
	}
	public int getType(){
		return type;
	}
	public void setDesc(String desc){
		this.desc=desc;
	}
	public String getDesc(){
		return desc;
	}
	private EnumMenuType(int type,String desc){
		this.type=type;
		this.desc=desc;
	}
	/**
	 * 查找枚举,不存在返回null
	 */
	public static EnumMenuType getEnum(Integer type,String desc){
		for(EnumMenuType e:values()){
			if((type!=null&&e.getType()==type)||(desc!=null&&e.getDesc().equals(desc))){
				return e;
			}
		}
		return null;
	}
	public static List<Map<String, Object>> getList(){
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		String key = "key";
		String value = "value";
		for(EnumMenuType e:values()){
			Map<String, Object> map = new HashMap<String, Object>();
			map.put(value, e.getType());
			map.put(key, e.getDesc());
			list.add(map);
		}
		return list;
	}
}
